<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>领域系统接口统计</title>
<link rel="stylesheet" type="text/css" href="../../../css/reset.css" />
<link rel="stylesheet" type="text/css" href="../../../css/css.css" />
<link rel="stylesheet" type="text/css"
	href="../../../js/jquery-easyui-1.4.3/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css"
	href="../../../js/jquery-easyui-1.4.3/themes/icon.css" />
<link rel="stylesheet" type="text/css"
	href="../../../js/SimpleTree1.3/js/tree_themes/SimpleTree.css" />
<link rel="stylesheet" type="text/css"
	href="../../../css/colorReset.css" />
<style>
.sel_con button {
	margin: 0 30px;
}
</style>
</head>

<body>
	<div class="main">
		<!-- 检索区域开始 -->
		<div class="sel_div">
			<table cellpadding="0" cellspacing="0" class="sel_con">
				<tr>
					<th colspan="6">数据检索</th>
				</tr>
				<tr>
					<td><label>所属领域：</label> <input type="text"
						name="comboxSearchfieldName" id="comboxSearchfieldName"
						class="text" /></td>
					<td><label>所属系统：</label> <input id="comboxSearchSystemName"
						name="comboxSearchSystemName" class="text" /></td>
					<td><label>接口数：</label> <select class="easyui-combobox"
						name="state" id="ifnull" style="width: 80px;">
							<option value="">全部</option>
							<option value="0">无</option>
							<option value="1">有</option>
					</select></td>
					<td><label>接口类型：</label> <select class="easyui-combobox"
						name="state" id="interfaceType" style="width: 80px;">
							<option value="">全部</option>
							<option value="0">HTTP</option>
							<option value="1">FTP</option>
							<option value="2">KettleJob</option>
					</select></td>


					<td>&nbsp;</td>
					<td style="width: 360px;">
						<button onclick="search()" class="query_btn easyui-linkbutton fl"
							iconCls="icon-search" style="outline: none;">查询</button>
						<button class="query_btn easyui-linkbutton fl"
							iconCls="icon-reset" onclick="onReset()" style="outline: none;">重置</button>
						<button onclick="exportData()"
							class="default_btn easyui-linkbutton fl" iconCls="icon-export"
							style="outline: none;">导出</button>
					</td>

				</tr>
			</table>
		</div>
		<div class="data_con">

			<table id="datagrid" style="height: 345px"
				data-options="fitColumns:true,toolbar:'#toolbox'">
			</table>


		</div>

	</div>



	<script type="text/javascript" src="/webjars/json3/3.3.2/json3.min.js"></script>
	<script type="text/javascript"
		src="../../../js/jquery-easyui-1.4.3/jquery.min.js"></script>
	<script type="text/javascript"
		src="../../../js/jquery-easyui-1.4.3/jquery.easyui.min.js"></script>
	<script type="text/javascript"
		src="../../../js/jquery-easyui-1.4.3/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="../../../js/cook/public.js"></script>
	<script type="text/javascript" src="../../../js/cook/constants.js"></script>
	<script>
var field = null;
var fieldSystem = null;
var ifNull = null;
var g_totalNum = 1000000;
$(document).ready(function(){
	
		//所属领域下拉框
		$('#comboxSearchfieldName').combobox({
			url: BASE_URL_FIELD_SEARCH + '/findAllOfCurrentUserCanManage' + '?v=' + Math.random(),
			valueField: 'id',
		    textField: 'name',
		    editable: false,
		    method:'get',
		    loadFilter: function(data){
		    	var allCheck = {'id':'','name':'全部'};
		    	data.content.unshift(allCheck);
		    	return data.content;
		    },
		    onSelect: function(record){
		    	comboxSearchSystemName.combobox({
                  disabled: false,
                  method:'get',
                  queryParams: {fieldId: record.id},
                  url: BASE_URL_FIELD_SYSTEM_SEARCH +'/findByFieldOfCurrentUserCanManage' + '?v=' + Math.random(),
                  valueField: 'id',
                  textField: 'name',
				  data:'',
      		    loadFilter: function(data){
      		    	var allCheck = {'id':'','name':'全部'};
      		    	data.content.unshift(allCheck);
      		    	return data.content;
      		    },
      		    onLoadSuccess:function(){
      		    	comboxSearchSystemName.combobox('setValue','');
      		    }
              }).load();
		    },
		    onLoadSuccess:function(){
		    	$('#cbSearch').combobox('setValue','');
		    }
		});
		
		//所属系统下拉框
		var comboxSearchSystemName = $('#comboxSearchSystemName').combobox({
          disabled: true,
          valueField: 'id',
          textField: 'name',
          editable: false,
		  data:[{id:'',name:'全部','selected':'true'}]
      });
		
		
		$("#datagrid").datagrid({
			url : BASE_URL_BASE_URL_SYSTEM_INTERFACE_CRUD + '/statistics/byFieldAndFieldSystem' + '?v=' + Math.random(),
			method:'get',
			autoRowHeight:true,
			singleSelect:true,
			striped:true,
			nowrap:false,
			pagination: true,
			pageSize:20,
			pageList:[10,20,50,100],
			columns:[[
						{field:'fieldName',title:'领域',width:100},
						{field:'systemName',title:'系统',width:70},
						{field:'interfaceType',title:'接口类型',width:70},
						{field:'interfaceAmount',title:'接口数',width:70}

			      ]],
			onSelect:function(rowIndex,rowData){
				$("#toolbar_edit").linkbutton('enable');
				$("#toolbar_delete").linkbutton('enable');
				$(this).datagrid('unselectRow', rowIndex);
			},
			onDblClickRow: function(rowIndex,rowData){
				var fieldName = encodeURI(rowData.fieldName);
				var systemName = encodeURI(rowData.systemName);
				var tabTitle = "";
				var tabUrl = "";
				if(rowData.interfaceType == "KettleJob"){
					tabTitle = "领域接口基本信息查询";
					tabUrl = "../pages/InterfaceMonitoring/OperationMonitoring/FieldInterfaceBasicInformationCheck.html?fieldName=" + 
					fieldName + "&systemName=" + systemName + "&v=" + Math.random();
					window.parent.OpenTab(tabTitle,tabUrl,"", true);
				}else if(rowData.interfaceType){
					tabTitle = "业务服务管理";
					tabUrl = "../pages/esb/ServiceManagement/businessServiceManagement.html?fieldName=" + 
					fieldName + "&systemName=" + systemName + "&v=" + Math.random();
					window.parent.OpenTab(tabTitle,tabUrl,"", true);
				}
				
			},
			loadFilter:function(data){
				var pageRowSize = $("#datagrid").datagrid("options").pageSize;
				var pageNumber = $("#datagrid").datagrid("options").pageNumber;
				if(data.content && data.content.length > 0)
				{
					if(data.content.length < pageRowSize)
					{
						//修正总数为正确的总记录数
						g_totalNum = pageRowSize * (pageNumber - 1) + data.content.length;
					}
					else
					{
						g_totalNum = g_totalNum > pageRowSize * pageNumber? g_totalNum:pageRowSize * (pageNumber + 1);
					}
				}
				else 
				{
					if(pageNumber > 1)
					{
						$.messager.alert('提示','<p>所输入页码数超出数据范围，请修正页码数!</p>','info');
					}
					g_totalNum = g_totalNum < pageRowSize * pageNumber? g_totalNum:pageRowSize * pageNumber;
				}
				return {
					total: g_totalNum,//data.content.length,
					rows: data.content
				};
			},
			onLoadSuccess: function(data) {
				//将表格里的html编码还原成原始字符，用于表单显示
				var rowDatas = $.data($("#datagrid")[0],"datagrid").data.rows;			
				$.data($("#datagrid")[0],"datagrid").data.rows = JSON.parse(JSON.stringify(rowDatas).replace(/&lt;/g, "<").replace(/&gt;/g, ">"));
				$(".pagination-info").html("当期显示" + rowDatas.length +　"条记录");
			},
			onBeforeLoad:function(param){
				g_totalNum = 1000000;
				param.page -= 1;
				param.size = param.rows;
				delete param.rows;
				
				var fieldId = $('#comboxSearchfieldName').combobox('getValue');
				if(fieldId !="全部"){
					param.fieldId = fieldId;
				}
				
				var fieldSystemId = $('#comboxSearchSystemName').combobox('getValue');
				if(fieldSystemId !="全部"){
					param.fieldSystemId = fieldSystemId;
				}
				var ifnull = $('#ifnull').combobox('getText');
				if(ifnull!="全部"){
					param.ifnull=ifnull;
				}
				var interfaceType = $('#interfaceType').combobox('getText');
				if(interfaceType!="全部"){
					param.interfaceType=interfaceType;
				}
				type=interfaceType;
				field=fieldId;
				fieldSystem=fieldSystemId;
				ifNull=ifnull;
			}
		});
		
		$("#datagrid").datagrid('getPager').pagination({   
		    displayMsg:'当前显示从 [{from}] 到 [{to}]',
		    layout: ['list', 'sep', 'prev', 'sep', 'manual', 'sep', 'next', 'sep', 'refresh'],
		    afterPageText: "页"
		});  

});
	//查询
	function search(){
		$('#datagrid').datagrid('load');
	}

	function　exportData(){
		$('#datagrid').datagrid('load');
		location.href= BASE_URL_EXPORTDATA_FILE + '/fileSystemInterfaceStatisticsExport?fieldId='+field+'&fieldSystemId='+fieldSystem +'&ifnull='+ifNull+'&interfaceType='+type;
	}
	
</script>
</body>
</html>
